package com.woniuxy.yuekeuser.controller;



import com.woniuxy.yuekeuser.common.AliUtil;
import com.woniuxy.yuekeuser.common.Result;
import com.woniuxy.yuekeuser.model.Order;
import com.woniuxy.yuekeuser.model.TOrder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
@CrossOrigin("*")
@RestController
@Slf4j
public class Pay {
    @RequestMapping("/pay/order")
    public Result goali(HttpSession session) {
        log.info("进入下单请求成功");
       Object obj= session.getAttribute("Order");
       TOrder order=null;
       if(obj instanceof TOrder){
           order=(TOrder) obj;
       }

        //order实际为前端传的数据，此处为测试假数据
//        order.setOrderPrice(0.01);
//        order.setOrderTime(LocalDateTime.now());
//        order.setOrderId(10112);
        //调用方法传入order对象返回封装好的Rusult,直接返回给前端就好
        Result pay = AliUtil.pay(order);
        return pay;
    }
}
